package org.apache.jsp.frame;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import com.util.SessionUtils;
import java.util.*;
import com.dao.GrantVerifyDAO;

public final class left_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {

  private static java.util.Vector _jspx_dependants;

  public java.util.List getDependants() {
    return _jspx_dependants;
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html; charset=gbk");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");

	GrantVerifyDAO dao = new GrantVerifyDAO();
	try{
		String roleId = SessionUtils.getRoleId(request);
		List list = dao.queryFunctions(roleId);

      out.write("\r\n");
      out.write("<html>\r\n");
      out.write("<head>\r\n");
      out.write("<META http-equiv=Pragma content=no-cache>\r\n");
      out.write("<META http-equiv=Cache-Control content=no-cache>\r\n");
      out.write("<META http-equiv=Expires content=0>\r\n");
      out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gbk\">\r\n");
      out.write("<title>left</title>\r\n");
      out.write("<link  href=\"../style/css/main.css\" rel=\"stylesheet\" type=\"text/css\"/>\r\n");
      out.write("<script type=\"text/javascript\" src=\"../style/scripts/private.js\"  language=\"JavaScript\"></script>\r\n");
      out.write("<style type=\"text/css\">\r\n");
      out.write("<!--\r\n");
      out.write("body {\r\n");
      out.write("\tbackground: url(../style/images/leftbg.jpg) no-repeat;\r\n");
      out.write("\tmargin-left: 0px;\r\n");
      out.write("\tmargin-top: 0px;\r\n");
      out.write("\tmargin-right: 0px;\r\n");
      out.write("\tmargin-bottom: 0px;\r\n");
      out.write("\tbackground-color: #E9F8FE;\r\n");
      out.write("}\r\n");
      out.write("-->\r\n");
      out.write("</style>\r\n");
      out.write("<script language=\"JavaScript1.2\">\r\n");
      out.write("scores = new Array(20);var numTotal=0;NS4 = (document.layers) ? 1 : 0;IE4 = (document.all) ? 1 : 0;ver4 = (NS4 || IE4) ? 1 : 0;if (ver4) {    with (document) {        write(\"<STYLE TYPE='text/css'>\");        if (NS4) {            write(\".parent {position:absolute; visibility:visible}\");            write(\".child {position:absolute; visibility:visible}\");            write(\".regular {position:absolute; visibility:visible}\")        }        else {            write(\".child {display:none}\")        }        write(\"</STYLE>\");    }}function getIndex(el) {    ind = null;    for (i=0; i<document.layers.length; i++) {        whichEl = document.layers[i];        if (whichEl.id == el) {            ind = i;            break;        }    }    return ind;}function arrange() {    nextY = document.layers[firstInd].pageY +document.layers[firstInd].document.height;    for (i=firstInd+1; i<document.layers.length; i++) {        whichEl = document.layers[i];        if (whichEl.visibility != \"hide\") {            whichEl.pageY = nextY;            nextY += whichEl.document.height;        }    }}function initIt(){    if (!ver4) return;    if (NS4) {        for (i=0; i<document.layers.length; i++) {            whichEl = document.layers[i];            if (whichEl.id.indexOf(\"Child\") != -1) whichEl.visibility = \"hide\";       }        arrange();    }    else {        divColl = document.all.tags(\"DIV\");        for (i=0; i<divColl.length; i++) {            whichEl = divColl(i);            if (whichEl.className == \"child\") whichEl.style.display = \"none\";        }    }}function expandIt(el) {\tif (!ver4) return;    if (IE4) {        whichEl1 = eval(el + \"Child\");\t\tfor(i=1;i<=numTotal;i++){\t\t\twhichEl = eval(scores[i] + \"Child\");\t\t\tif(whichEl!=whichEl1) {\t\t\t\twhichEl.style.display = \"none\";\t\t\t}\t\t}        whichEl1 = eval(el + \"Child\");        if (whichEl1.style.display == \"none\") {            whichEl1.style.display = \"block\";        }        else {            whichEl1.style.display = \"none\";        }    }    else {        whichEl = eval(\"document.\" + el + \"Child\");\t\tfor(i=1;i<=numTotal;i++){\t\t\twhichEl = eval(\"document.\" + scores[i] + \"Child\");\t\t\tif(whichEl!=whichEl1) {\t\t\t\twhichEl.visibility = \"hide\";\t\t\t}\t\t}        if (whichEl.visibility == \"hide\") {            whichEl.visibility = \"show\";        }        else {            whichEl.visibility = \"hide\";        }        arrange();    }}onload = initIt;\r\n");
      out.write("</script>\r\n");
      out.write("<script language=JavaScript>\r\n");
      out.write("// Arrays for nodes and icons\r\n");
      out.write("var nodes\t\t= new Array();;\r\n");
      out.write("var openNodes\t= new Array();\r\n");
      out.write("var icons\t\t= new Array(18);\r\n");
      out.write("var imgid = \"\";\r\n");
      out.write("var modName = \"\";\r\n");
      out.write("var modURL = \"\";\r\n");
      out.write("// Loads all icons that are used in the tree\r\n");
      out.write("function preloadIcons() {\r\n");
      out.write("\ticons[0] = new Image();\r\n");
      out.write("\ticons[0].src = \"tree/image/img/plus.gif\";\r\n");
      out.write("\ticons[1] = new Image();\r\n");
      out.write("\ticons[1].src = \"tree/image/img/plusbottom.gif\";\r\n");
      out.write("\ticons[2] = new Image();\r\n");
      out.write("\ticons[2].src = \"tree/image/img/minus.gif\";\r\n");
      out.write("\ticons[3] = new Image();\r\n");
      out.write("\ticons[3].src = \"tree/image/img/minusbottom.gif\";\r\n");
      out.write("\ticons[4] = new Image();\r\n");
      out.write("\ticons[4].src = \"tree/image/img/folder\"+imgid+\".gif\";\r\n");
      out.write("\ticons[5] = new Image();\r\n");
      out.write("\ticons[5].src = \"tree/image/img/folderopen\"+imgid+\".gif\";\r\n");
      out.write("}\r\n");
      out.write("// Create the tree\r\n");
      out.write("function createTree(arrName, startNode, openNode,imageid,modelName,modelURL) {\r\n");
      out.write("\timgid = imageid;\r\n");
      out.write("\tmodName = modelName;\r\n");
      out.write("\tmodURL = modelURL;\r\n");
      out.write("\tnodes = arrName;\r\n");
      out.write("\tif (nodes.length > 0) {\r\n");
      out.write("\t\tpreloadIcons();\r\n");
      out.write("\t\tif (startNode == null) startNode = 0;\r\n");
      out.write("\t\tif (openNode != 0 || openNode != null) setOpenNodes(openNode);\r\n");
      out.write("\t\r\n");
      out.write("\t\tif (startNode !=0) {\r\n");
      out.write("\t\t\tvar nodeValues = nodes[getArrayId(startNode)].split(\"|\");\r\n");
      out.write("\t\t\tdocument.write(\"<a href=\\\"\" + nodeValues[3] + \"\\\" onmouseover=\\\"window.status='\" + nodeValues[2] + \"';return true;\\\" onmouseout=\\\"window.status=' ';return true;\\\" target=mainFrame><img src=\\\"tree/image/img/folderopen\"+imgid+\".gif\\\" align=\\\"absbottom\\\" alt=\\\"\\\" border=\\\"0\\\"/>\" + nodeValues[2] + \"</a><br />\");\r\n");
      out.write("\t\t} else document.write(\"<a href=\\\"\" + modURL + \"\\\" onmouseover=\\\"window.status='\" + modName + \"';return true;\\\" onmouseout=\\\"window.status=' ';return true;\\\" target=mainFrame><img src=\\\"tree/image/img/base\"+imgid+\".gif\\\" align=\\\"absbottom\\\" alt=\\\"\\\" border=\\\"0\\\" />&nbsp;&nbsp;\"+modName+\"<br /></a>\");\r\n");
      out.write("\t\r\n");
      out.write("\t\tvar recursedNodes = new Array();\r\n");
      out.write("\t\taddNode(startNode, recursedNodes);\r\n");
      out.write("\t}\r\n");
      out.write("}\r\n");
      out.write("// Returns the position of a node in the array\r\n");
      out.write("function getArrayId(node) {\r\n");
      out.write("\tfor (i=0; i<nodes.length; i++) {\r\n");
      out.write("\t\tvar nodeValues = nodes[i].split(\"|\");\r\n");
      out.write("\t\tif (nodeValues[0]==node) return i;\r\n");
      out.write("\t}\r\n");
      out.write("}\r\n");
      out.write("// Puts in array nodes that will be open\r\n");
      out.write("function setOpenNodes(openNode) {\r\n");
      out.write("\tfor (i=0; i<nodes.length; i++) {\r\n");
      out.write("\t\tvar nodeValues = nodes[i].split(\"|\");\r\n");
      out.write("\t\tif (nodeValues[0]==openNode) {\r\n");
      out.write("\t\t\topenNodes.push(nodeValues[0]);\r\n");
      out.write("\t\t\tsetOpenNodes(nodeValues[1]);\r\n");
      out.write("\t\t}\r\n");
      out.write("\t} \r\n");
      out.write("}\r\n");
      out.write("// Checks if a node is open\r\n");
      out.write("function isNodeOpen(node) {\r\n");
      out.write("\tfor (i=0; i<openNodes.length; i++)\r\n");
      out.write("\t\tif (openNodes[i]==node) return true;\r\n");
      out.write("\treturn false;\r\n");
      out.write("}\r\n");
      out.write("// Checks if a node has any children\r\n");
      out.write("function hasChildNode(parentNode) {\r\n");
      out.write("\tfor (i=0; i< nodes.length; i++) {\r\n");
      out.write("\t\tvar nodeValues = nodes[i].split(\"|\");\r\n");
      out.write("\t\tif (nodeValues[1] == parentNode) return true;\r\n");
      out.write("\t}\r\n");
      out.write("\treturn false;\r\n");
      out.write("}\r\n");
      out.write("// Checks if a node is the last sibling\r\n");
      out.write("function lastSibling (node, parentNode) {\r\n");
      out.write("\tvar lastChild = 0;\r\n");
      out.write("\tfor (i=0; i< nodes.length; i++) {\r\n");
      out.write("\t\tvar nodeValues = nodes[i].split(\"|\");\r\n");
      out.write("\t\tif (nodeValues[1] == parentNode)\r\n");
      out.write("\t\t\tlastChild = nodeValues[0];\r\n");
      out.write("\t}\r\n");
      out.write("\tif (lastChild==node) return true;\r\n");
      out.write("\treturn false;\r\n");
      out.write("}\r\n");
      out.write("// Adds a new node in the tree\r\n");
      out.write("function addNode(parentNode, recursedNodes) {\r\n");
      out.write("\tfor (var i = 0; i < nodes.length; i++) {\r\n");
      out.write("\r\n");
      out.write("\t\tvar nodeValues = nodes[i].split(\"|\");\r\n");
      out.write("\t\tif (nodeValues[1] == parentNode) {\r\n");
      out.write("\t\t\t\r\n");
      out.write("\t\t\tvar ls\t= lastSibling(nodeValues[0], nodeValues[1]);\r\n");
      out.write("\t\t\tvar hcn\t= hasChildNode(nodeValues[0]);\r\n");
      out.write("\t\t\tvar ino = isNodeOpen(nodeValues[0]);\r\n");
      out.write("\r\n");
      out.write("\t\t\t// Write out line & empty icons\r\n");
      out.write("\t\t\tfor (g=0; g<recursedNodes.length; g++) {\r\n");
      out.write("\t\t\t\tif (recursedNodes[g] == 1) document.write(\"<img src=\\\"tree/image/img/line.gif\\\" align=\\\"absbottom\\\" alt=\\\"\\\" border=\\\"0\\\"/>\");\r\n");
      out.write("\t\t\t\telse  document.write(\"<img src=\\\"tree/image/img/empty.gif\\\" align=\\\"absbottom\\\" alt=\\\"\\\" border=\\\"0\\\"/>\");\r\n");
      out.write("\t\t\t}\r\n");
      out.write("\r\n");
      out.write("\t\t\t// put in array line & empty icons\r\n");
      out.write("\t\t\tif (ls) recursedNodes.push(0);\r\n");
      out.write("\t\t\telse recursedNodes.push(1);\r\n");
      out.write("\r\n");
      out.write("\t\t\t// Write out join icons\r\n");
      out.write("\t\t\tif (hcn) {\r\n");
      out.write("\t\t\t\tif (ls) {\r\n");
      out.write("\t\t\t\t\tdocument.write(\"<a href=\\\"javascript: oc(\" + nodeValues[0] + \", 1);\\\"><img id=\\\"join\" + nodeValues[0] + \"\\\" border=\\\"0\\\" src=\\\"tree/image/img/\");\r\n");
      out.write("\t\t\t\t\t \tif (ino) document.write(\"minus\");\r\n");
      out.write("\t\t\t\t\t\telse document.write(\"plus\");\r\n");
      out.write("\t\t\t\t\tdocument.write(\"bottom.gif\\\" align=\\\"absbottom\\\" alt=\\\"Open/Close node\\\" /></a>\");\r\n");
      out.write("\t\t\t\t} else {\r\n");
      out.write("\t\t\t\t\tdocument.write(\"<a href=\\\"javascript: oc(\" + nodeValues[0] + \", 0);\\\"><img id=\\\"join\" + nodeValues[0] + \"\\\" border=\\\"0\\\" src=\\\"tree/image/img/\");\r\n");
      out.write("\t\t\t\t\t\tif (ino) document.write(\"minus\");\r\n");
      out.write("\t\t\t\t\t\telse document.write(\"plus\");\r\n");
      out.write("\t\t\t\t\tdocument.write(\".gif\\\" align=\\\"absbottom\\\" alt=\\\"Open/Close node\\\" /></a>\");\r\n");
      out.write("\t\t\t\t}\r\n");
      out.write("\t\t\t} else {\r\n");
      out.write("\t\t\t\tif (ls) document.write(\"<img src=\\\"tree/image/img/join.gif\\\" align=\\\"absbottom\\\" alt=\\\"\\\" border=\\\"0\\\" />\");\r\n");
      out.write("\t\t\t\telse document.write(\"<img src=\\\"tree/image/img/joinbottom.gif\\\" align=\\\"absbottom\\\" alt=\\\"\\\" border=\\\"0\\\" />\");\r\n");
      out.write("\t\t\t}\r\n");
      out.write("\r\n");
      out.write("\t\t\t// Start link\r\n");
      out.write("\t\t\tdocument.write(\"<a href=\\\"\" + nodeValues[3] + \"\\\" onmouseover=\\\"window.status='\" + nodeValues[2] + \"';return true;\\\" onmouseout=\\\"window.status=' ';return true;\\\" target=mainFrame>\");\r\n");
      out.write("\t\t\t\r\n");
      out.write("\t\t\t// Write out folder & page icons\r\n");
      out.write("\t\t\tif (hcn) {\r\n");
      out.write("\t\t\t\tdocument.write(\"<img id=\\\"icon\" + nodeValues[0] + \"\\\"  border=\\\"0\\\" src=\\\"tree/image/img/folder\"+imgid+\"\")\r\n");
      out.write("\t\t\t\t\tif (ino) document.write(\"open\");\r\n");
      out.write("\t\t\t\tdocument.write(\".gif\\\" align=\\\"absbottom\\\" alt=\\\"Folder\\\" />\");\r\n");
      out.write("\t\t\t} else document.write(\"<img id=\\\"icon\" + nodeValues[0] + \"\\\"  border=\\\"0\\\" src=\\\"tree/image/img/page\"+imgid+\".gif\\\" align=\\\"absbottom\\\" alt=\\\"Page\\\" />\");\r\n");
      out.write("\t\t\t\r\n");
      out.write("\t\t\t// Write out node name\r\n");
      out.write("\t\t\tdocument.write(nodeValues[2]);\r\n");
      out.write("\r\n");
      out.write("\t\t\t// End link\r\n");
      out.write("\t\t\tdocument.write(\"</a><br />\");\r\n");
      out.write("\t\t\t\r\n");
      out.write("\t\t\t// If node has children write out divs and go deeper\r\n");
      out.write("\t\t\tif (hcn) {\r\n");
      out.write("\t\t\t\tdocument.write(\"<div id=\\\"div\" + nodeValues[0] + \"\\\"\");\r\n");
      out.write("\t\t\t\t\tif (!ino) document.write(\" style=\\\"display: none;\\\"\");\r\n");
      out.write("\t\t\t\tdocument.write(\">\");\r\n");
      out.write("\t\t\t\taddNode(nodeValues[0], recursedNodes);\r\n");
      out.write("\t\t\t\tdocument.write(\"</div>\");\r\n");
      out.write("\t\t\t}\r\n");
      out.write("\t\t\t\r\n");
      out.write("\t\t\t// remove last line or empty icon \r\n");
      out.write("\t\t\trecursedNodes.pop();\r\n");
      out.write("\t\t}\r\n");
      out.write("\t}\r\n");
      out.write("}\r\n");
      out.write("// Opens or closes a node\r\n");
      out.write("function oc(node, bottom) {\r\n");
      out.write("\tvar theDiv = document.getElementById(\"div\" + node);\r\n");
      out.write("\tvar theJoin\t= document.getElementById(\"join\" + node);\r\n");
      out.write("\tvar theIcon = document.getElementById(\"icon\" + node);\r\n");
      out.write("\t\r\n");
      out.write("\tif (theDiv.style.display == 'none') {\r\n");
      out.write("\t\tif (bottom==1) theJoin.src = icons[3].src;\r\n");
      out.write("\t\telse theJoin.src = icons[2].src;\r\n");
      out.write("\t\ttheIcon.src = icons[5].src;\r\n");
      out.write("\t\ttheDiv.style.display = '';\r\n");
      out.write("\t} else {\r\n");
      out.write("\t\tif (bottom==1) theJoin.src = icons[1].src;\r\n");
      out.write("\t\telse theJoin.src = icons[0].src;\r\n");
      out.write("\t\ttheIcon.src = icons[4].src;\r\n");
      out.write("\t\ttheDiv.style.display = 'none';\r\n");
      out.write("\t}\r\n");
      out.write("}\r\n");
      out.write("// Push and pop not implemented in IE(crap!    don? know about NS though)\r\n");
      out.write("if(!Array.prototype.push) {\r\n");
      out.write("\tfunction array_push() {\r\n");
      out.write("\t\tfor(var i=0;i<arguments.length;i++)\r\n");
      out.write("\t\t\tthis[this.length]=arguments[i];\r\n");
      out.write("\t\treturn this.length;\r\n");
      out.write("\t}\r\n");
      out.write("\tArray.prototype.push = array_push;\r\n");
      out.write("}\r\n");
      out.write("if(!Array.prototype.pop) {\r\n");
      out.write("\tfunction array_pop(){\r\n");
      out.write("\t\tlastElement = this[this.length-1];\r\n");
      out.write("\t\tthis.length = Math.max(this.length-1,0);\r\n");
      out.write("\t\treturn lastElement;\r\n");
      out.write("\t}\r\n");
      out.write("\tArray.prototype.pop = array_pop;\r\n");
      out.write("}\r\n");
      out.write("\r\n");
      out.write("</script>\r\n");
      out.write("<script type=\"text/javascript\">\r\n");
      out.write("\tvar Tree = new Array;\r\n");
      out.write("\t// nodeId | parentNodeId | nodeName | nodeUrl\r\n");
      out.write("\tvar modelName = \"首页\";\r\n");
      out.write("\tvar modelURL = \"blank.jsp\";\r\n");
      out.write("\tvar imageid = \"7\";\r\n");

	
	for(int i=0; i<list.size(); i++){				
		Map map = (Map) list.get(i);
		String functionid = (String) map.get("FUNCTIONID");
		String parentid = (String) map.get("PARENTID");
		String name = (String) map.get("NAME");
		String url =  (String)request.getContextPath() + "/"+(String) map.get("URL");
		String aaa = "Tree["+i+"]"+"='"+functionid+"|"+parentid+"|"+name+"|"+url+"'";
		out.println(aaa);
	}

      out.write("\r\n");
      out.write("\r\n");
      out.write("</script>\r\n");
      out.write("</head>\r\n");
      out.write("<body class=\"application-body\">\r\n");
      out.write("<table width=\"171\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin-top:10px\">\r\n");
      out.write("\t<tr>\r\n");
      out.write("\t\t<td align=\"center\">\r\n");
      out.write("\t\t<div style=\"position:absolute;top:0px;left:expression(document.body.clientWidth-this.offsetWidth);width:8px;height:100%;border-width:0px;\">\r\n");
      out.write("\t\t</div>\r\n");
      out.write("\t\t\t<table width=\"171\" border=\"0\" align=\"center\" cellpadding=\"1\" cellspacing=\"1\">\r\n");
      out.write("\t\t\t\t<div id=\"tree\"><script type=\"text/javascript\">createTree(Tree,0,0,imageid,modelName,modelURL);</script></div>\r\n");
      out.write("\t\t\t</table>\r\n");
      out.write("\t\t</td>\r\n");
      out.write("  \t</tr>\r\n");
      out.write("</table>\r\n");
      out.write("<div style=\"position:absolute; bottom:2px; left:2px; border:#0099FF 1px solid\">\r\n");
      out.write("<table width=\"167\" height=\"78\" align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\r\n");
      out.write("\t<tr>\r\n");
      out.write("\t\t<td colspan=\"2\" align=\"left\" valign=\"middle\">&nbsp;<font color=\"blue\"><strong>机构：");
      out.print(SessionUtils.getOrgName(request));
      out.write("</strong></font></td>\r\n");
      out.write("\t</tr>\r\n");
      out.write("\t<tr>\r\n");
      out.write("\t\t<td colspan=\"2\" align=\"left\" valign=\"middle\">&nbsp;<font color=\"blue\"><strong>角色：");
      out.print(SessionUtils.getRoleName(request));
      out.write("</strong></font></td>\r\n");
      out.write("\t</tr>\r\n");
      out.write("\t<tr>\r\n");
      out.write("\t\t<td align=\"left\" valign=\"middle\" width=\"95%\">&nbsp;<font color=\"blue\"><strong>用户：");
      out.print(SessionUtils.getUserName(request));
      out.write("</strong></font></td>\r\n");
      out.write("\t\t<td align=\"center\" valign=\"middle\" width=\"57\" nowrap=\"nowrap\"><a href=\"../logout.do\" target=\"_parent\"><font color=\"red\"><strong>[ 注 销 ]</strong></font></a></td>\r\n");
      out.write("\t</tr>\r\n");
      out.write("</table>\r\n");
      out.write("</div>\r\n");
      out.write("</body>\r\n");
      out.write("</html>\r\n");

	}catch(Exception e){
		e.printStackTrace();
	}finally{
		if (dao != null) dao.disConnect();
	}

    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
